CROSS_COMPILE ?= arm-linux-gnueabihf-
TARGET		  ?= default_demo
LD_FILE       ?= 

CC 		:= $(CROSS_COMPILE)gcc
LD		:= $(CROSS_COMPILE)ld
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump

OBJS 	:= start.o main.o

$(TARGET).bin:$(OBJS)
	$(LD) -T$(LD_FILE) -o $(TARGET).elf $^
	$(OBJCOPY) -O binary -S $(TARGET).elf $@
	$(OBJDUMP) -D -m arm $(TARGET).elf > $(TARGET).dis

%.o:%.s
	$(CC) -Wall -nostdlib -c -O2 -o $@ $<
	
%.o:%.S
	$(CC) -Wall -nostdlib -c -O2 -o $@ $<
	
%.o:%.c
	$(CC) -Wall -nostdlib -c -O2 -o $@ $<

.PHONY: clean	
clean:
	rm -rf *.o  *.imx $(TARGET).bin $(TARGET).elf $(TARGET).dis

